import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace CmtContentFeedbackApi {
  export interface Feedback {
    id?: number;
    communityId?: number;
    merchantId?: number;
    userId?: number;
    feedbackType?: number;
    category?: string;
    title?: string;
    content?: string;
    images?: string;
    contactPhone?: string;
    feedbackStatus?: number;
    reply?: string;
    replyUserId?: number;
    replyTime?: string;
    likeCount?: number;
    createTime?: string;
  }

  export interface FeedbackPageReqVO extends PageParam {
    feedbackType?: number;
    feedbackStatus?: number;
    userId?: number;
    createTime?: string[];
  }
}

export function getFeedbackPage(params: CmtContentFeedbackApi.FeedbackPageReqVO) {
  return requestClient.get<PageResult<CmtContentFeedbackApi.Feedback>>(
    '/cmt/content-feedback/page',
    { params },
  );
}

export function getFeedback(id: number) {
  return requestClient.get<CmtContentFeedbackApi.Feedback>(
    `/cmt/content-feedback/get?id=${id}`,
  );
}

export function createFeedback(data: CmtContentFeedbackApi.Feedback) {
  return requestClient.post('/cmt/content-feedback/create', data);
}

export function updateFeedback(data: CmtContentFeedbackApi.Feedback) {
  return requestClient.put('/cmt/content-feedback/update', data);
}

export function deleteFeedback(id: number) {
  return requestClient.delete(`/cmt/content-feedback/delete?id=${id}`);
}

export function deleteFeedbackList(ids: number[]) {
  return requestClient.delete(
    `/cmt/content-feedback/delete-list?ids=${ids.join(',')}`,
  );
}

export function exportFeedback(params: CmtContentFeedbackApi.FeedbackPageReqVO) {
  return requestClient.download('/cmt/content-feedback/export-excel', { params });
}
